package ldh.im.fxbase.util;

import java.lang.reflect.Method;

public class ReflectionUtil {

    public static Method getMethod(Class clazz, String methodName, Class[] args) throws NoSuchMethodException {
        Method method = clazz.getDeclaredMethod(methodName, args);
        if (method == null) {
            if (clazz == Object.class) {
                throw new NoSuchMethodException(clazz.getName() + "不存在这个方法：" + methodName);
            }
            return getMethod(clazz.getSuperclass(), methodName, args);
        }
        return method;
    }
}
